# Maintainer: christian rebischke <chris.rebischke@archlinux.org>
# Maintainer: Christian Heusel <gromit@archlinux.org>

pkgname=gopass-hibp
pkgver=1.15.10
pkgrel=1
pkgdesc="haveibeenpwnd.com integration for gopass"
arch=('loong64' 'x86_64')
url="https://github.com/gopasspw/gopass-hibp"
license=('MIT')
depends=('glibc')
makedepends=('go')
source=("${pkgname}-${pkgver}.tar.gz::https://github.com/gopasspw/gopass-hibp/archive/refs/tags/v${pkgver}.tar.gz")
sha512sums=('02fbaaa3584925e602a34dc6d519fe98e6d546f80d72d3c68dff1951435619981101ea7851074844846c348cecf5e8306a4c2a188753d3c67ea1d9d323a69843')
options=('!lto')

prepare(){
  cd ${pkgname}-${pkgver}
  sed -i 's|-gcflags="-trimpath=$(GOPATH)" -asmflags="-trimpath=$(GOPATH)"||' Makefile
  sed -i 's/install-completion//g' Makefile
}

build(){
  cd ${pkgname}-${pkgver}
  export CGO_CPPFLAGS="${CPPFLAGS}"
  export CGO_CFLAGS="${CFLAGS}"
  export CGO_CXXFLAGS="${CXXFLAGS}"
  export CGO_LDFLAGS="${LDFLAGS}"
  export GOFLAGS="-buildmode=pie -trimpath -mod=readonly -modcacherw"
  make
}

package() {
  cd ${pkgname}-${pkgver}
  make DESTDIR="${pkgdir}" PREFIX="/usr" install
  install -Dm644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}
